#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int main()
{
	int n,c,dp[maxn];
	scanf("%d",&n);
	dp[0]=1;
	while(scanf("%d",&c)!=EOF)
		for(int i=c;i<=n;i++)
			dp[i]+=dp[i-c];
	printf("%d",dp[n]); 
	return 0;
}
